import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import firstPage from '../page/routerComponent/firstPage.vue'
import firstInnerPage from '../page/routerComponent/firstInnerPage.vue'

Vue.use(Router)

const useStore = () => import(/* webpackChunkName: "useStore" */ '../page/useStore.vue')
const useRouter = () => import(/* webpackChunkName: "useRouter" */ '../page/useRouter.vue')
export default new Router({
    routes: [
        {
            path: '/',
            name: 'HelloWorld',
            meta: 'HelloWorld',
            component: HelloWorld
        },
        {
            path: '/useStore',
            name: 'useStore',
            meta: 'useStore',
            component: useStore
        },
        {
            path: '/useRouter',
            name: 'useRouter',
            meta: {
                requireAuth: true,
            },
            component: useRouter,
            children: [
                {
                    path: 'firstPage',
                    name: 'firstPage',
                    props: (route) => ({
                        testProps: route.query.type
                    }),
                    meta: {
                        requireAuth: true,
                        title: 'firstPage'
                    },
                    component: firstPage,
                    children: [
                        {
                            path: 'firstInnerPage',
                            name: 'firstInnerPage',
                            component: firstInnerPage,
                        }
                    ]
                }
            ]
        },
    ],
    scrollBehavior(to, from, savedPosition) {
        // console.log(to)
        // console.log(from)
        // console.log(savedPosition)
        return { x: 0, y: 0 }
    }
})
